home *** CD-ROM | disk | FTP | other *** search
/ Your Choice 1 / your choice.zip / your choice / PRGMMING / SORTING / DOCUMENT.TXT < prev    next >
Text File  |  1994-01-15  |  35KB  |  820 lines

  1. INTRODUCTION       1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
  2.  
  3.  
  4. Congratulations in your interest in the Sorting Tutor!  You
  5. have chosen a high quality tutor that will provide you with
  6. the best opportunity to understand the concepts behind
  7. computerized sorting.
  8.  
  9. This manual is a reference to the Sorting Tutor.  The
  10. Sorting Tutor offers a complete learning guide to six common
  11. sorting algorithms.  We trust you will find this guide an
  12. informative aid that will allow you to successfully build
  13. sorting algorithms necessary in the construction of various
  14. computer programs.
  15.  
  16.  
  17. Who Should Read This Manual
  18.  
  19. This manual is intended for novice to advanced programmers. 
  20. For the novice, Chapter 1 provides basic information for
  21. starting and using the Sorting Tutor.  Chapters 3 & 6
  22. introduce the novice programmer to three basic sorting
  23. algorithms.
  24.  
  25. For the advanced programmer, Chapters 3 through 8 explain
  26. each of the nine sorting algorithms in full detail.  The
  27. advanced programmer may simply go to the sorting algorithm
  28. that is of most interest.  
  29.  
  30. For all users, chapters 2 through 8 provide examples for
  31. exchange and insertion sorts.  
  32.  
  33.  
  34. What You Should Already Know
  35.  
  36. In order to get the most out of this manual, you should be
  37. familiar with some fundamental programming aspects.  You
  38. should know how to code LOOPs, IF-THEN-ELSEs, ARRAYS (one
  39. dimensional), and ASSIGNMENT statements.
  40.  
  41. You should also be familiar with QuickBASIC's primary
  42. commands since the program examples utilized in the Sorting
  43. Tutor are in QuickBASIC.  This does not mean that you have
  44. to know every QuickBASIC command, but you should be
  45. comfortable in relating the commands used in the Sorting
  46. Tutor with the language that you are most familiar with.
  47.  
  48.  
  49. How to Use This Manual
  50.  
  51. This manual is not meant to be read from cover to cover.  It
  52. is a reference manual, so use it to look up specific
  53. problems that you want to solve.  To get the most out of
  54. this manual, refer to the glossary whenever you are not 
  55. entirely clear about any computer terms used.
  56. INTRODUCTION
  57.  
  58. INTRODUCTION
  59.  
  60.  
  61. What This Manual is About
  62.  
  63.    For ease of reference, this manual is organized (except for Getting 
  64.    Started, chapter 1) according to the options on the main menu screen.
  65.    Each sorting algorithm displayed on the main menu can be classified
  66.    into the following two types:
  67.  
  68.  
  69.        Exchange sorts:  (BUBBLE, SHAKER, and QUICK sort) 
  70.           Exchange sorts utilize exchanges as an indirect
  71.           method of selection, and speed up towards the
  72.           end.
  73.  
  74.            Insertion sorts:  (LINEAR INSERTION, BINARY
  75.           INSERTION, and SHELL sort)  Insertion sorts take
  76.           each successive piece of data and place it into
  77.           the correct position relative to all previously
  78.           considered items.
  79.  
  80.  
  81. The manual consists largely of information on six sorting
  82. algorithms; BUBBLE, SHAKER, QUICK, LINEAR INSERTION, BINARY
  83. INSERTION, and SHELL sort.  The code that is used for each
  84. sorting algorithm is just one way to code an application; it
  85. is not the only way.  The reference section in this manual
  86. provides additional information on these sorting algorithms.
  87.  
  88. GETTING STARTED    2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 
  89.  
  90.  
  91. The program disk that you have received with this package is
  92. ready to run.  You may start this program by simply placing
  93. it into drive A: and enter: SORTING.  The introduction screen
  94. is displayed on your screen after you have pressed the enter
  95. key.  To continue to the main menu screen, press any key on
  96. the keyboard. 
  97.  
  98. The main menu that appears on the screen after the introduction
  99. can be visualized as the table of contents for your system.  It 
  100. is a menu containing all major features in the system.  The main 
  101. menu displays six sorting algorithms that are grouped into two types 
  102. (Insertion and Exchange).
  103.  
  104.  
  105. Receiving HELP by Pressing F1
  106.  
  107. Use the Sorting Tutor's Help key (F1) to answer any questions that you
  108. may have.  The Help key is context-sensitive, which means the Sorting 
  109. Tutor will offer help to current situations.  For example, if you are 
  110. currently at the main menu and press the F1 key, the system will offer 
  111. help that is related to the main menu screen. 
  112.  
  113.  
  114. Selecting a Menu Option
  115.  
  116. The Sorting Tutor offers you an an attractive and user friendly menu 
  117. environment.  You may use the following keys when selecting an option from 
  118. any menu screen that the Sorting Tutor displays:
  119.  
  120.      UP ARROW      Allows you to highlight the previous item on the menu.
  121.  
  122.      DOWN ARROW    Highlights the next item in the menu.
  123.  
  124.      FIRST LETTER  When you press the first highlighted menu letter, the 
  125.                    computer will automatically choose this option.
  126.  
  127.  
  128. ** Please Note:  Additional help is available by highlighting the desired
  129.    letter option (use the arrow keys) and reading the message located at
  130.    the bottom of the screen.
  131.  
  132.  
  133. System Requirements
  134.  
  135. There are certain hardware and software requirements to run the Sorting 
  136. Tutor.  The following requirements are needed before the Sorting Tutor can 
  137. function:
  138.  
  139.      
  140.    MINIMUM INTERNAL MEMORY:      640K RAM
  141.  
  142.    MINIMUM DISK CONFIGURATION:   One diskette drive (5¼" or 3½" Drive)
  143.  
  144.    OPERATING SYSTEM:             PC-DOS, Ver. 2.0 or higher
  145.                                  MS-DOS, Ver. 2.0 or higher 
  146.  
  147.    COMPUTERS:                    IBM PC, PC-XT, PC-AT, PS/2, or 100% 
  148.                                  compatible
  149.  
  150.    GRAPHICS CARD:                Required to display graphs or receive 
  151.                                  context sensitive HELP.
  152. GETTING STARTED
  153.  
  154.  
  155. Installing The Program to a Hard Drive   (optional)
  156.  
  157.    Although this program can run on a floppy disk, this program
  158.    can also be installed on a hard drive with .360MEG of
  159.    available disk space.
  160.  
  161.    As you will see, installing this program on a hard drive is
  162.    very easy.  The following steps will install the original
  163.    program from drive A to drive C:
  164.  
  165.           1.  Place the program disk in drive A.
  166.           2.  Type:   
  167.                    A:   
  168.               and then press Enter.
  169.           3.  Type:
  170.                    INSTALL
  171.               and then press Enter.
  172.  
  173.    Once you have completed these three steps, the computer will
  174.    copy all the necessary files on drive A to a sub-directory
  175.    in drive C  (called SORTING).  This should take
  176.    approximately 1.5 minutes.  After all drive activity has
  177.    stopped, you may remove the original diskette and store it
  178.    in a safe place.
  179. GENERAL SORTING INFORMATION
  180.  
  181.  
  182. This section covers the first option on the main menu screen and explains
  183. the importance of sorting data elements on a computer.  If you are unfamiliar 
  184. with the concepts behind sorting, please take the time to read this section 
  185. on the main menu.  You should also use the glossary in the back of this 
  186. manual whenever a term is unclear to you.
  187.  
  188. Since this is a information section, the F1 key will not provide help in 
  189. this section.
  190. BUBBLE SORT        3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3
  191.  
  192.  
  193. By selecting this option from the main menu screen, you can choose any option
  194. that is displayed on the submenu screen.  A SUB-MENU will illustrate the 
  195. options that are available to you.  This section describes these options.
  196.  
  197. The bubble sort is one of the easiest sorting routines to learn.
  198.  
  199.  
  200. Background Information
  201.  
  202.    The background information on the bubble sort offers novice programmers a
  203.    description of the algorithm and code that is used in this simulation.
  204.  
  205.    The word 'BUBBLE' refers to the way in which a data item works its way up
  206.    the list until it is in ascending or descending order.  This technique is
  207.    the easiest way for novice programmers to learn computerized sorting.  In
  208.    practice, when data is very close to being sorted, a bubble sorting 
  209.    routine with a simple flag is an easy solution.
  210.  
  211.    Although the bubble sort is a routine designed to sort any number of 
  212.    elements in an array, sorting large amounts of data would dramatically 
  213.    increase sorting time.  The bubble sort technique requires approx. ½ * N²
  214.    operations (N is the total number of elements in the array).  
  215.  
  216.  
  217. Graphical Sorting
  218.  
  219.    This process graphically demonstrates the bubble sorting technique.  You 
  220.    will be required to enter the number of elements to sort.  This number can
  221.    be as large as 3000 or as small as 2, the Sorting Tutor requires more time
  222.    to complete a sort of larger numbers.  
  223.  
  224.    This process illustrates the characteristics of the bubble sort.  The 
  225.    X-axis (bottom horizontal line) represents the array positions, and the
  226.    Y-axis (left vertical line) is the number assigned to that position.  
  227.    White dots (black in Fig. 3-2) represent unsorted data and red dots 
  228.    represent sorted data.  A red diagonal line will form (ie., array(1) = 1,
  229.    array(2) = 2 ... array(n) = n) as the data is sorted.
  230.  
  231.    After you enter the number of data items to sort, the Sorting Tutor will 
  232.    generate and sort this random set of unique integers (no number will occur
  233.    twice).  To provide an overview of this sorting process, the demonstration
  234.    is completely automatic.  You may press the pause key (CTRL-S) to freeze
  235.    the current screen display.  Press any key when you are ready to resume 
  236.    this demo.  By pressing the ESC key, the Sorting Tutor will return you to
  237.    the submenu screen displayed in figure 3-1.  Once you have completed the 
  238.    demo, the Sorting Tutor will also display the time it took to complete the
  239.    bubble sorting process.
  240.  
  241.    As you can observe from this process, bubble sorting is a very slow and 
  242.    time consuming process.  The shaker sort algorithm offers an improvement
  243.    over the bubble sorting technique (refer to chapter 4).
  244.  
  245.  
  246.    ** Please Note:  Due to physical mapping of dots on the screen, the 
  247.       Sorting Tutor may misrepresent (ie., erase 2 dots instead of one)
  248.       numbers greater than 190.  You may enter numbers greater than 190, but
  249.       keep in mind that all of the dots may not be visible.
  250.  
  251. BUBBLE SORT
  252.  
  253.  
  254. Program Code Sorting
  255.  
  256.    This process will use a QuickBASIC algorithm to demonstrate the bubble 
  257.    sort.  Before the process can start, you must answer these two questions:
  258.  
  259. QUESTION 1:
  260.  
  261.    Enter the number of seconds to pause between sorting steps:
  262.    ( 0 will wait for the user to press any key. ):  [   ]
  263.  
  264.  
  265. ANSWER:   Use a number of seconds between each step of the sorting
  266.           algorithm.  This number can be any number between 0 and
  267.           99999.  Enter a '0' to control each step.  10 to 20 seconds
  268.           is normal for beginners.
  269.  
  270.  
  271. QUESTION 2:
  272.  
  273.    Do you want to enter the sample data (2 to 11 items)? (Y\N):
  274.  
  275.  
  276. ANSWER:   Enter 'Y' for YES and 'N' for NO.  If you want to
  277.           type in your own words, enter 'Y'.  A 'N' response will
  278.           instruct the Sorting Tutor to choose 11 words at random from
  279.           its data base.
  280.  
  281.  
  282.  
  283.    Once you have responded to the two questions above, the Sorting Tutor will
  284.    sort the array.  If you find that the process is going too fast, you may 
  285.    press the PAUSE key (or CTRL-S) to freeze the screen display.  Press any 
  286.    key when you are ready to resume the process.  If you understand the 
  287.    bubble sorting concept or simply want to return to the submenu, press the 
  288.    ESC key to permit the Sorting Tutor to operate at its fastest speed.
  289.  
  290.  
  291.   ** Please Note:  Pressing F1 on any line of code in this sorting algorithm
  292.      will offer you a description of the program code that is displayed on 
  293.      the screen.
  294.  
  295.  
  296. Return to MAIN MENU
  297.  
  298.    By pressing the 'R' key at the submenu screen (you may also highlight 
  299.    this option), the Sorting Tutor will display the main menu screen.
  300. SHAKER SORT        4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 
  301.  
  302.  
  303. By selecting this option from the main menu screen, you can choose any
  304. option that is displayed on the submenu screen.  This submenu will illustrate
  305. the options that are available to you.  This section describes these options.
  306.  
  307.  
  308. Background Information
  309.  
  310.    The background information on the shaker sort offers novice to advanced
  311.    programmers a description of the algorithm and code that is used in this
  312.    simulation.
  313.  
  314.    Like the BUBBLE sort, the word 'SHAKER' refers to the way in which a data 
  315.    item works its way up and down the list until it is in ascending or 
  316.    descending order.  This technique is compared to a cocktail SHAKER for its
  317.    process of sorting data.  
  318.  
  319.    The shaker sort is also designed just like the BUBBLE sort except this 
  320.    algorithm utilizes a boolean (TRUE\FALSE) flag to indicate whether the 
  321.    elements being compared are already in order.  If they are in their proper
  322.    place, then these elements are considered to be sorted.   The improvements
  323.    to the shaker sort may seem good, but it really makes little difference 
  324.    when sorting a large number elements (the number of exchanges is identical
  325.    to those of the bubble sort).
  326.  
  327.  
  328. Graphical Sorting
  329.  
  330.    This process graphically demonstrates the shaker sort technique.  You will
  331.    be required to enter the number of elements to sort.  This number can be 
  332.    as large as 3000 or as small as 2, but the Sorting Tutor requires more time
  333.    to complete a sort of larger numbers.  
  334.  
  335.    The graph illustrates the characteristics of the shaker sort.  The X-axis
  336.    (bottom horizontal line) represents the array positions, and the Y-axis
  337.    (left vertical line) is the number assigned to that position.  White dots 
  338.    represent unsorted data and red dots represent sorted data.  A red 
  339.    diagonal line will form (ie., array(1) = 1, array(2) = 2 ... array(n) = n)
  340.    as the data is sorted.
  341.  
  342.    After you enter the number of data items to sort, the Sorting Tutor will 
  343.    generate and sort this random set of unique integers (no number will occur
  344.    twice).  To provide an overview of this sorting process, the demonstration
  345.    is completely automatic.  You may press the pause key (CTRL-S) to freeze 
  346.    the current screen display.  Press any key when you are ready to resume 
  347.    this demo.  By pressing the ESC key, the Sorting Tutor will return you to
  348.    the submenu screen displayed in figure 4-1.  Once you have completed the 
  349.    demo, the Sorting Tutor will also display the time it took to complete the
  350.    shaker sorting process.
  351.  
  352.    As you can observe from comparing the shaker and bubble sorting graphs, 
  353.    the shaker sort works from both sides of the graph.  Although this 
  354.    algorithm may seem better, the time to sort larger numbers is about the 
  355.    same.
  356.  
  357.  
  358.    ** Please Note:  Due to physical mapping of dots on the screen, the 
  359.       Sorting Tutor may misrepresent (ie., erase 2 dots instead of one) 
  360.       numbers greater than 190.  You may enter numbers greater than 190, but
  361.       keep in mind that all of the dots may not be visible.
  362. SHAKER SORT
  363.  
  364.  
  365. Program Code Sorting
  366.  
  367.    ( See Program Code Sorting for Bubble Sorting )
  368.  
  369. Return to MAIN MENU
  370.  
  371.    By pressing the 'R' key at the submenu screen (you may also highlight
  372.    this option), the Sorting Tutor will display the main menu screen.
  373. QUICKSORT          5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
  374.  
  375.  
  376. By selecting this option from the main menu screen, you can choose any 
  377. option that is displayed on the submenu screen.  The submenu will illustrate
  378. the options that are available to you.  This section describes these options.
  379.  
  380.  
  381. Background Information
  382.  
  383.    The background information on the quick sort offers you a description of 
  384.    the algorithm and code that is used in this simulation.  The quick sort is
  385.    well suited for advanced programmers.
  386.  
  387.    Although it may seem that the quick sort is the fastest algorithm, it is 
  388.    not always as quick as expected.  The goal in the quick sort is to select
  389.    a pivot which is well positioned relative to the data.  A poor use of the
  390.    quick sort would be to sort data that is already completely sorted.
  391.  
  392.  
  393. Graphical Sorting
  394.  
  395.    This process graphically demonstrates the quick sort technique.  You will
  396.    be required to enter the number of elements to sort.  This number can be 
  397.    as large as 3000 or as small as 2, but the Sorting Tutor requires more 
  398.    time to complete a sort of larger numbers.  
  399.  
  400.    The graph displayed in figure 5-2 illustrates the characteristics of the 
  401.    quick sort.  The X-axis (bottom horizontal line)  represents the array 
  402.    positions, and the Y-axis (left vertical line) is the number assigned to
  403.    that position.  White dots represent unsorted data and red dots represent 
  404.    sorted data.  A red diagonal line will form (ie., array(1) = 1, array(2)
  405.    = 2 ... array(n) = n) as the data is sorted.
  406.  
  407.    After you enter the number of data items to sort, the Sorting Tutor will
  408.    generate and sort this random set of unique integers (no number will occur
  409.    twice).  To provide an overview of this sorting process, the demonstration
  410.    is completely automatic.  You may press the pause key (CTRL-S) to freeze 
  411.    the current screen display.  Press any key when you are ready to resume 
  412.    this demo.  By pressing the ESC key, the Sorting Tutor will return you to
  413.    the submenu screen.
  414.  
  415.    Once you have completed the demo, the Sorting Tutor will also display the
  416.    time it took to complete the shaker sorting process.
  417.  
  418.    As you can observe from this process, the quick sort is very fast in its 
  419.    sorting procedure (3000 elements take approx. 29 seconds on a 386 33MHZ 
  420.    computer).  You can also see how quickly the partitions (square blocks) 
  421.    are formed and sorted from this process.
  422.  
  423.    ** Please Note:  Due to physical mapping of dots on the screen, the 
  424.       Sorting Tutor may misrepresent (ie., erase 2 dots instead of one)
  425.       numbers greater than 190.  You may enter numbers greater than 190,
  426.       but keep in mind that all of the dots may not be visible.
  427.  
  428. Program Code Sorting
  429.  
  430.  
  431.    This process will use a QuickBASIC algorithm to demonstrate the quick 
  432.    sort.  Before the process can start, you must answer these two questions:
  433.  
  434.    **** SEE PROGRAM SORTING under the bubble sort for more help.
  435.  
  436. Return to MAIN MENU
  437.  
  438.    By pressing the 'R' key at the submenu screen (you may also highlight this
  439.    option), the Sorting Tutor will display the main menu screen.
  440. LINEAR INSERTION SORT   6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
  441.  
  442.  
  443. By selecting this option from the main menu screen, you can choose any
  444. option that is displayed on the submenu screen.  The submenu will illustrate
  445. the options that are available to you.  This section describes these options.
  446.  
  447. The Linear insertion sort is one of the basic examples of  INSERTION SORTS. 
  448.  
  449.  
  450. Background Information
  451.  
  452.    The background information on the linear insertion sort offers novice and
  453.    advanced programmers a description of the algorithm and code that is used
  454.    in this simulation.
  455.  
  456.    The linear insertion process is similar to the process of picking up cards
  457.    one by one in a bridge game.  When you choose a new card, you insert it 
  458.    into its correct position (RELATIVE TO THE OTHER CARDS IN YOUR HAND).
  459.  
  460.  
  461. Graphical Sorting
  462.  
  463.    This process graphically demonstrates the linear insertion sort technique.
  464.    You will be required to enter the number of elements to sort.  This number
  465.    can be as large as 3000 or as small as 2, but the Sorting Tutor requires 
  466.    more time to complete a sort of larger numbers.  
  467.  
  468.    The graph illustrates the characteristics of the linear insertion sort.  
  469.    The X-axis (bottom  horizontal line)  represents the array positions, and
  470.    the  Y-axis (left vertical line) is the number assigned to that position.
  471.    White dots (black in Fig. 6-2) represent unsorted data and red dots
  472.    represent sorted data.  A red diagonal line will form (ie., array(1) = 1,
  473.    array(2) = 2 ... array(n) = n) as the data is sorted.
  474.  
  475.    After you enter the number of data items to sort, the Sorting Tutor will
  476.    generate and sort this random set of unique integers (no number will occur
  477.    twice).  To provide an overview of this sorting process, the demonstration
  478.    is completely automatic.  You may press the pause key (CTRL-S) to freeze 
  479.    the current screen display.  Press any key when you are ready to resume
  480.    this demo.  By pressing the ESC key, the Sorting Tutor will return you to
  481.    the submenu screen.  Once you have completed the demo, the Sorting Tutor
  482.    will also display the time it took to finish the linear insertion 
  483.    sorting process.
  484.  
  485.    As you can observe from this process, the linear insertion sort inserts 
  486.    all unsorted data into a sorted "diagonal like" line.  Although this is 
  487.    the same process that is used in binary insertion sort, linear insertion 
  488.    sort take a longer amount of time to insert unsorted elements.
  489.  
  490.  
  491.    ** Please Note:  Due to physical mapping of dots on the screen, the 
  492.       Sorting Tutor may misrepresent (ie., erase 2 dots instead of one)
  493.       numbers greater than 190.  You may enter numbers greater than 190, but
  494.       keep in mind that all of the dots may not be visible.
  495. LINEAR INSERTION SORT
  496.  
  497.  
  498. Program Code Sorting
  499.  
  500.    This process will use a QuickBASIC algorithm to demonstrate the linear 
  501.    insertion sort.  Before the process can start, you must answer these two
  502.    questions (SEE program sorting for BUBBLE SORT).
  503.  
  504.  
  505. Return to MAIN MENU
  506.  
  507.    By pressing the 'R' key at the submenu screen (you may also highlight this
  508.    option), the Sorting Tutor will display the main menu screen.
  509. BINARY INSERTION SORT   7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7
  510.  
  511.  
  512. By selecting this option from the main menu screen, you can choose any 
  513. option that is displayed on the submenu screen.  The submenu illustrates the
  514. options that are available to you.  This section describes these options.
  515.  
  516.  
  517. Background Information
  518.  
  519.    The background information on the binary insertion sort offers novice and
  520.    advanced programmers a description of the algorithm and code that is used 
  521.    in this simulation.
  522.  
  523.    The binary insertion sort works by dividing sorted elements into equal 
  524.    halves.  The next step is to compare the two halves and determine in which
  525.    half the new data element should be placed.  This process is repeated 
  526.    until the new element can be inserted into the array.
  527.  
  528.    Although the above practice may seem to involve many steps, the binary
  529.    insertion sort requires an amazingly small number of "guesses" to find
  530.    its position.  For example, this process could easily guess your name
  531.    within 20 tries.  If your name is in a phone directory, locate the person
  532.    that is in the center of the book (approx.).  Now, decide whether this 
  533.    name is before or after your name.  Since you are searching in smaller and
  534.    smaller halves, the dividing property of the binary insertion process will
  535.    find your name within 20 guesses (unless the directory has more than 219 =
  536.    1,048,576 entries). 
  537.  
  538.  
  539. Graphical Sorting
  540.  
  541.    This process graphically demonstrates the binary insertion sort technique.
  542.    You will be required to enter the number of elements to sort.  This number
  543.    can be as large as 3000 or as small as 2, but the Sorting Tutor will 
  544.    require more time to complete a sort of larger numbers.  The graph 
  545.    displayed in figure 7-2 illustrates the characteristics of the binary
  546.    insertion sort.  The X-axis (bottom  horizontal line)  represents the 
  547.    array positions, and the  Y-axis (left vertical line) is the number 
  548.    assigned to that position.  White dots (black in Fig. 7-2) represent 
  549.    unsorted data and red dots represent sorted data.  A red diagonal line
  550.    will form (ie., array(1) = 1, array(2) = 2 ... array(n) = n) as the data
  551.    is sorted.
  552.  
  553.    After you enter the number of data items to sort, the Sorting Tutor will
  554.    generate and sort this random set of unique integers (no number will occur
  555.    twice).  To provide an overview of this sorting process, the demonstration
  556.    is completely automatic.  You may press the pause key (CTRL-S) to freeze 
  557.    the current screen display. Press any key when you are ready to resume 
  558.    this demo.  By pressing the ESC key, the Sorting Tutor will return you to
  559.    the submenu screen.  Once you have completed the demo, the Sorting Tutor
  560.    will also display the time it took to finish the binary insertion sorting
  561.    process.
  562.  
  563.    As you can observe from this process, the binary insertion sort inserts
  564.    all unsorted data into a sorted "diagonal like" line.  Although this is
  565.    the same process that is used in linear insertion sort, the binary 
  566.    insertion sort can quickly find a position to insert unsorted elements.
  567.  
  568.    ** Please Note:  Due to physical mapping of dots on the screen, the 
  569.       Sorting Tutor may misrepresent (ie., erase 2 dots instead of one)
  570.       numbers greater than 190.  You may enter numbers greater than 190, but
  571.       keep in mind that all of the dots may not be visible.
  572. BINARY INSERTION SORT
  573.  
  574.  
  575. Program Code Sorting
  576.  
  577.    This process will use a QuickBASIC algorithm to demonstrate the binary 
  578.    insertion sort.  Before the process can start, you must answer two 
  579.    questions:   (SEE PROGRAM CODE SORTING UNDER bubble sort)
  580.  
  581.  
  582. Return to MAIN MENU
  583.  
  584.    By pressing the 'R' key at the submenu screen (you may also highlight this
  585.    option), the Sorting Tutor will display the main menu screen.
  586. SHELL SORT         8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8
  587.  
  588.  
  589. y selecting this option from the main menu screen, you can choose 
  590. any option that is displayed on the submenu screen.  The submenu will 
  591. illustrate the options that are available to you.  This section describes
  592. these options.
  593.  
  594. Although advanced programmers can study the quick sorting time, the Shell 
  595. sort is also well suited for novice programmers.
  596.  
  597.  
  598. Background Information
  599.  
  600.    The background information on the Shell sort offers novice programmers 
  601.    a description of the algorithm and code that is used in this simulation.
  602.  
  603.    The Shell sort (named after Donald L. Shell) is a variation of the 
  604.    insertion sort.  When sorting large arrays, this sorting algorithm is much
  605.    faster than the BUBBLE sort.  The Shell sort compares items that are a 
  606.    given number of elements away (usually INT(n/2)) and it will eventually
  607.    compare items that are close together.  If these items are out of their
  608.    proper order, a swap is performed.  The Shell sort yields faster results
  609.    than would be expected by examining its algorithm.
  610.  
  611.  
  612. Graphical Sorting
  613.  
  614.    This process graphically demonstrates the Shell sort technique.  You will
  615.    be required to enter the number of elements to sort.  This number can be
  616.    as large as 3000 or as small as 2, but the Sorting Tutor will require more
  617.    time to complete a sort of larger numbers.  
  618.  
  619.    The graph displayed in figure 8-2 illustrates the characteristics of the
  620.    Shell sort.  The X-axis (bottom horizontal line)  represents the array 
  621.    positions, and the Y-axis (left vertical line) is the number assigned to
  622.    that position.  White dots (black in Fig. 8-2) represent unsorted data and
  623.    red dots represent sorted data.  A red diagonal line will form (ie., 
  624.    array(1) = 1, array(2) = 2 ... array(n) = n) as the data is sorted.
  625.  
  626.    After you enter the number of data items to sort, the Sorting Tutor will
  627.    generate and sort this random set of unique integers (no number will occur
  628.    twice).  To provide an overview of this sorting process, the demonstration
  629.    is completely automatic.  You may press the pause key (CTRL-S) to freeze 
  630.    the current screen display.  Press any key when you are ready to resume
  631.    this demo.  By pressing the ESC key, the Sorting Tutor will return you to
  632.    the submenu screen. Once you have completed the demo, the Sorting Tutor
  633.    will also display the time it took to complete the Shell sorting process.
  634.  
  635.    As you can observe from this process, the Shell sort quickly brings data
  636.    items closer to the sorted diagonal line.  Although this is not as fast as
  637.    the recursive quick sort, the memory required to operate the Shell sort is
  638.    much lower (recursive algorithms require more memory for each recursive
  639.    call).
  640.  
  641.    ** Please Note:  Due to physical mapping of dots on the screen, the 
  642.       Sorting Tutor may misrepresent (ie., erase 2 dots instead of one)
  643.       numbers greater than 190.  You may enter numbers greater than 190,
  644.       but keep in mind that all of the dots may not be visible.
  645. SHELL SORT
  646.  
  647.  
  648. Program Code Sorting
  649.  
  650.  
  651.    This process will use a QuickBASIC algorithm to demonstrate the Shell 
  652.    sort.   Before the process can start, you must answer these two 
  653.    questions: (SEE program sorting for the bubble sort)
  654.  
  655.  
  656. Return to MAIN MENU
  657.  
  658.    By pressing the 'R' key at the submenu screen (you may also highlight
  659.    this option), the Sorting Tutor will display the main menu screen.
  660. CHANGE COLOR ON\OFF     9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9
  661.  
  662.  
  663. If you are using a monochrome monitor that does not display colors, you
  664. may use this option to turn the colors off. When you select this option
  665. again, the colors will be enabled.
  666.  
  667.  
  668.    ** Please Note:  If you do not have a color adapter card for your 
  669.       computer, changing the color will NOT enable you to display graphs.
  670.       Refer to your operations manual that came with your computer to verify
  671.       if your computer can display graphics.
  672. GLOSSARY                                                   [A] - [D]
  673.  
  674.  
  675.  
  676.  
  677. ALGORITHM  An algorithm is a sequence of instructions that tell
  678. how to solve a particular problem.  An algorithm must be
  679. specified exactly, so there can be no doubt about what to do
  680. next, and it must have a finite number of steps.  A computer
  681. program is an algorithm.
  682.  
  683. ARRAY  An array is a collection of data that is referred to by
  684. one name.
  685.  
  686. ARROW KEYS  The cursor keys are located on the right hand side of
  687. the keyboard.  They are labeled with both numbers and arrows. 
  688. These keys can be used to highlight a menu option.  The light on
  689. the Num. Lock key must be off in order to allow these keys to
  690. move the cursor.
  691.  
  692. BYTE   A byte is the amount of memory space needed to store one
  693. character, which is normally 8 bits.  A computer with 8-bit bytes
  694. can distinguish 256 different characters.
  695.  
  696. COMPATIBLE   Two computers are said to be compatible if they can
  697. use the same programs.
  698.  
  699. COMPILER   A compiler is a computer program that translates a
  700. high level language into machine language.
  701.  
  702. COPY   To copy information is to transfer the information to
  703. another location, leaving the original information unchanged.
  704.  
  705. CURSOR   The cursor is the symbol on a computer terminal that
  706. shows you where the next character you type will appear on the
  707. screen.
  708.  
  709. DATA  Data is factual information.  Data is the plural of the
  710. word datum, which means "a singlefact."
  711.  
  712. DATA BASE   A data base is a collection of data stored on a
  713. computer storage medium, such as a disk, that can be used for
  714. more than one purpose.
  715.  
  716. DATA BASE MANAGEMENT   Data base management is the task of
  717. storing data in a data base and retrieving information from that
  718. data.
  719.  
  720. DISK DRIVE   A disk drive is a device that enables a computer to
  721. read and write data on disks.
  722.  
  723. DOS   DOS (Disk Operating System) has been used by many computer
  724. manufacturers as a name for various operating systems.
  725.  
  726.  
  727. GLOSSARY                                                   [E] - [Q]
  728.  
  729.  
  730.  
  731.  
  732. ENTER KEY   The enter key on a computer terminal is the key you
  733. press at the end of each line in order to enter the contents of
  734. that line into the computer.
  735.  
  736. F1  This is a function key which is located on the left side of
  737. the keyboard (or along the top).  Function keys are referred to
  738. as F1, F2, F3, ... F12.  When an instruction lists a number
  739. preceded by an F, the function keys are used.
  740.  
  741. FILE   A file is a collection of information stored as records.
  742.  
  743. FLOPPY DISK   A floppy disk is a computer storage medium made of
  744. plastic which is covered with a magnetic coating.
  745.  
  746. HARD COPY   A hard copy is a printout on paper of computer
  747. output.
  748.  
  749. HARD DISK   A hard disk is a storage medium using rigid aluminum
  750. disks coated with iron oxide.
  751.  
  752. HARDWARE   The hardware in a computer system consists of all the
  753. physical elements in the computer such as integrated circuits,
  754. wires, and terminals.
  755.  
  756. INPUT   The input to a computer is the data is that are fed into
  757. the computer for it to process.
  758.  
  759. MACHINE LANGUAGE   A machine language contains instructions that
  760. a computer can execute directly.
  761.  
  762. MAIN MENU  The main menu is the table of contents for your
  763. system.  It is a menu containing all major features in the
  764. system.
  765.  
  766. MEG   MEG stands for megabyte which refers to a memory size of
  767. 1,048,576 bytes.
  768.  
  769. MS-DOS   MS-DOS, the MicroSoft Disk Operating System, is an
  770. operating system for computers that use the 8086 or 8088
  771. microprocessor.
  772.  
  773. OUTPUT   The output of a computer is the information that the
  774. computer generates as a result of its calculations.
  775.  
  776. QuickBASIC   QuickBASIC is one of the easiest computer languages
  777. to learn.  B.A.S.I.C. stands for Beginners All-purpose Symbolic
  778. Instructional Code and was originally developed by John Kemeny
  779. and Thomas Kurtz.
  780.  
  781.  
  782. GLOSSARY                                                   [R] - [S]
  783.  
  784.  
  785. RECURSION   The use of a program that calls itself while it is
  786. being executed.
  787.  
  788. RUN   Used to describe the execution process of a program.  In
  789. general, most programs are executed at the DOS prompt by typing
  790. in the name of the program and pressing the ENTER key.
  791.  
  792. SCREEN  The information displayed on your monitor.
  793.  
  794. SORT   To sort a group of items, such as the elements in an array or
  795. the records of a file, is to arrange them in numerical or alphabetical
  796. order.
  797. REFERENCES
  798.  
  799.  
  800.  
  801.  
  802. The follow references may offer you additional help on the
  803. sorting process:
  804.  
  805.  
  806.  
  807. Box, Richard and Stephen Lacey, April, 1991.  "A Fast, Easy
  808.      Sort", BYTE, V16.,  pp. 315-320.
  809.  
  810. Knuth, Donald E., The Art of Computer Programming, Vol. 3:   
  811.      Sorting and Searching, Addison-Wesley, 1973, pp. 73-    
  812.      180.
  813.  
  814. Lorin, Harold, Sorting and Sort Systems, Addison-Wesley,     
  815.      1975, pp. 1-173.
  816.  
  817. Wirth, Nicklaus, Algorithms + Data Structures = Programs,    
  818.      Prentice-Hall, 1976, pp. 56-87.
  819.  
  820.